             package com.java.diagnostics.visualizer.memory.parser;
             
             import com.java.diagnostics.visualizer.data.DataLevel;
             import com.java.diagnostics.visualizer.data.SourceData;
             import com.java.diagnostics.visualizer.data.StructuredData;
             import com.java.diagnostics.visualizer.data.StructuredDataBuilder;
             import com.java.diagnostics.visualizer.data.TupleDataBuilder;
             import com.java.diagnostics.visualizer.data.axes.AxisPair;
             import com.java.diagnostics.visualizer.data.axes.XDataAxis;
             import com.java.diagnostics.visualizer.data.axes.YDataAxis;
             import com.java.diagnostics.visualizer.exceptions.GCAndMemoryVisualizerException;
             import com.java.diagnostics.visualizer.factory.DataFactory;
             import com.java.diagnostics.visualizer.factory.SourceDataFactory;
             import com.java.diagnostics.visualizer.impl.factory.LogFactory;
             import com.java.diagnostics.visualizer.memory.util.Messages;
             import com.java.diagnostics.visualizer.metadata.TupleMetaData;
             import com.java.diagnostics.visualizer.metadata.TupleMetaData.TableField;
             import com.java.diagnostics.visualizer.metadata.TupleMetaData.TableType;
             import com.java.diagnostics.visualizer.properties.OutputProperties;
             import com.java.diagnostics.visualizer.sources.Source;
             import java.io.BufferedReader;
             import java.util.Set;
             import java.util.logging.Level;
             import java.util.logging.Logger;
             
             public class InstancePerfMonParser
               extends NativeMemoryParser
             {
               public static final String HEADER = "Virtual Bytes";
               private static final Logger TRACE = LogFactory.getTrace(InstancePerfMonParser.class);
               
               private TupleDataBuilder reservedAddressTuple;
               
               private AxisPair memoryAxisPair;
               private static final String SPACE = "\" \"";
               private static final String QUOTE = "\"";
               private static final String WINDOWS = "windows";
               
               public SourceData parse(Source source, OutputProperties properties)
                 throws GCAndMemoryVisualizerException
               {
                 TRACE.entering(this.className, "parse");
                 
                 this.isGoodData = false;
                 initialiseTuples();
                 this.xAxis = NativeMemoryAxes.prepareXAxis(source, properties);
                 
                 YDataAxis memoryAxis = 
                   NativeMemoryAxes.preparePagesMemoryAxis(properties);
                 
                 this.memoryAxisPair = factory.createAxisPair(this.xAxis, memoryAxis);
                 
                 this.reservedAddressTuple = 
                   createTuple("NativeMemoryLabels.reserved", this.memoryAxisPair);
                 
                 this.reservedAddressTuple.setTupleMetaData(new TupleMetaData(
                   TupleMetaData.TableType.ARITHMETIC, new TupleMetaData.TableField[] { TupleMetaData.TableField.MEAN, 
                   TupleMetaData.TableField.MIN, TupleMetaData.TableField.MAX }));
                 
                 StructuredData platform = hiddenFactory.createStructuredData("platform", 
                   "platform");
                 ((StructuredDataBuilder)platform).put("1", "windows");
                 try
                 {
                   String variantIdentifier = source.getVariantIdentifier();
                   this.sourceData = 
                     SOURCE_DATA_FACTORY.createSourceData(variantIdentifier);
                   
                   BufferedReader reader = source.getSafeBufferedStreamReader();
                   
                   String line = reader.readLine();
                   
                   line = reader.readLine();
                   while (line != null) {
                     handleLine(line, reader);
                     line = reader.readLine();
                   }
                   
                   if (this.isGoodData)
                   {
                     this.sourceData.addData(platform, DataLevel.VARIANT);
                     writeOutSourceData();
                   }
                   this.xAxis.updateNormalisation(this.sourceData);
                   reader.close();
                 } catch (Exception e) {
                   TRACE.log(Level.WARNING, e.toString(), e);
                   this.sourceData = null;
                 }
                 TRACE.exiting(this.className, "parse");
                 return this.sourceData;
               }
               
               private void handleLine(String line, BufferedReader reader)
               {
                 String[] parts = line.split(",");
                 double timestamp = 0.0D;
                 double virtualBytes = 0.0D;
                 
                 if ((parts.length > 1) && (!parts[0].equals("\" \"")) && 
                   (!parts[1].equals("\" \""))) {
                   timestamp = WindowsDateConverter.parseDate(parts[0].replaceAll(
                     "\"", ""));
                   virtualBytes = Double.parseDouble(parts[1].replaceAll("\"", 
                     ""));
                   
                   this.xAxis.setX(timestamp);
                   this.isGoodData = true;
                   this.reservedAddressTuple.addDataPoint(virtualBytes, this.currentComment);
                 }
               }
               
               private TupleDataBuilder createTuple(String label, AxisPair axisPair) {
                 TupleDataBuilder tuple = factory.createTupleData(label, 
                   Messages.getString(label), axisPair);
                 this.allTuples.add(tuple);
                 
                 return tuple;
               }
             }


